import barcode from '../lib/qrcode/barcode.js'
import qrcode from '../lib/qrcode/qrcode.js'

const convert_length = (length) => {
    return Math.round(wx.getSystemInfoSync().windowWidth * length / 750);
}

const barc = (id, code, width, height) => {
    barcode.code128(wx.createCanvasContext(id), code, convert_length(width), convert_length(height))
}

const qrc = (id, code, width, height) => {
    qrcode.api.draw(code, {
        ctx: wx.createCanvasContext(id),
        width: convert_length(width),
        height: convert_length(height)
    })
}

export default{
  barcode: barc,
  qrcode: qrc
}